home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 04 January 1999
- //
- //<doc>
- //<name stringArrayCount>
- //<owner "Alias|Wavefront Unsupported">
- //
- //<synopsis>
- // int stringArrayCount(string $item, string[] $list)
- //
- //<description>
- // Return the number of times the string in $item
- // occurs in the string array $list.
- // Zero is returned if the string is not in the list.
- //
- //<flags>
- // string $item The string item to search for in the string array.
- // string[] $list A list of string values.
- //
- //<returns>
- // int : The number of occurrences of the string item in the string array.
- //
- //<examples>
- // string $array1[] = {"item1", "item2", "item1"};
- // // Result: item1 item2 item1 //
- // int $count = stringArrayCount("item1", $array1);
- // // Result: 2 //
- // $count = stringArrayCount("item2", $array1);
- // // Result: 1 //
- // $count = stringArrayCount("plotz", $array1);
- // // Result: 0 //
- //
- //</doc>
- //
-
- global proc int stringArrayCount(string $item, string $list[])
- {
- int $result = 0;
-
- string $listItem;
-
- for ($listItem in $list) {
- if ($item == $listItem) $result++;
- }
-
- return $result;
- }
-